import axios from '@/api/http'
import filehttp from '@/api/file-http'

/**
 * 保存dashboard信息
 */
export const saveDashboard = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/save',
  })

/**
 * 更新dashboard信息
 */
export const updateDashboard = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/update',
  })

export const getDashboard = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/queryById',
  })

export const getDashboardByProjectId = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/queryByProjectId',
  })

export const deleteDashboard = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/deleteById',
  })

// 发布可视化
export const publishDashboard = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/publish',
  })

/**
 * 画布复制
 * @param options
 * @returns
 */
export const copyDashboard = (options: any) =>
  axios.request({
    ...options,
    url: '/dashboard/copy',
  })

/**
 * 取消可视化发布
 */
export const cancelPublish = (options?: any) =>
  axios.request({
    ...options,
    url: '/dashboard/unstuck',
  })

/**
 * 词云上传图片
 */
export const uploadPhoto = (options?: any) =>
  filehttp.request({
    ...options,
    url: '/dataset/uploadPhoto',
  })

/**
 * 词云删除图片
 */
export const deletePhoto = (options?: any) =>
  filehttp.request({
    ...options,
    url: '/dataset/delete/photo',
  })

/**
 * 画布 undo、 redo
 */
export const snapshot = (options?: any) =>
  axios.request({
    ...options,
    url: 'dashboard/snapshot',
  })
